﻿Imports DTO
Public Class DoanhSo_DAL
    Dim connect As Connection
    Dim stringCommand As String
    Dim doanhSo As DoanhSo
    Dim ds_doanhSo As List(Of DoanhSo)

    Public Function LoadData() As List(Of DoanhSo)
        connect = New Connection()
        stringCommand = "Select * From DoanhSo"
        ds_doanhSo = New List(Of DoanhSo)
        Dim dt As New DataTable()
        dt = connect.LoadData(stringCommand)
        For i As Integer = 0 To dt.Rows.Count - 1
            Dim id As Integer = dt.Rows(i)(0)
            Dim ngay As DateTime = dt.Rows(i)(1)
            Dim soLuongTiecCuoi As Integer = dt.Rows(i)(2)
            Dim doanhThu As Double = dt.Rows(i)(3)
            Dim tiLe As Integer = dt.Rows(i)(4)

            doanhSo = New DoanhSo(id, ngay, soLuongTiecCuoi, doanhThu, tiLe)
            ds_doanhSo.Add(doanhSo)
        Next
        Return ds_doanhSo
    End Function

    Public Function Insert(ByVal doanhSo As DoanhSo)
        connect = New Connection()
        stringCommand = "Insert DoanhSo(ID,Ngay,SoLuongTiecCuoi,DoanhThu,TiLe) Values('" & doanhSo.ID & "','" & doanhSo.Ngày & "','" & doanhSo.Số_Lượng_Tiệc_Cưới & "','" & doanhSo.Doanh_Thu & "','" & doanhSo.Tỉ_Lệ & ")"
        Return connect.ExecuteData(stringCommand)
    End Function
End Class
